<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>

  const arr1 = [1, 2, 3];

  function Man(params) {
    Person.call(this, params)
  }

  function Person() {

  }

  Man.prototype.__proto__ = Object.create(Person.prototype);

  const man = new Man();

  // console.log(arr1 instanceof Array); //true
  // console.log(arr1 instanceof Object);//false  true
  // console.log(new RegExp(/123g/) instanceof Object);// false  true
  // console.log(new Date() instanceof Array); // false
  // console.log(new Blob() instanceof Object); // true
  // console.log(man instanceof Man); // true
  // console.log(man instanceof Person); // true
  // console.log(man instanceof Object); // true

  // instanceof : 判断的是 实例 和 原生的类或者自己创建的类 的关系
  // 判断的是 实例的原型链是否包含该类的原型
  // man.__proto__.__proto__.__proto__.__proto__ === Object.prototype

  function myInstanceof(ins, fn) {
    if ((!ins || !fn) && (fn.prototype) && (ins.__proto__)) {
      return false;
    }

    let current = ins.__proto__;
    while (current) {
      if (current === fn.prototype) {
        return true
      }
      current = current.__proto__;
    }

    return false;
  }

  console.log(myInstanceof(new Blob(), Blob)); // true

</script>
</body>
</html>
